<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%-- 引入页面头 --%>
<%@ include file="/pageHead.jsp"%>
<form name="form1" id="form1"
	action="<%-- ${systemctx}/sample/saveSample.web --%>" method="post">
	<div class="pageMain">
		<div class="pageTitle"><%=MessageResourcesUtils.getMessage(request, "systemmanage.servicemanagement.title") %><span></span><%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargemanage.title") %></div>
		<div class="pageBody">
			<div class="form-group">
				<ul>
					<li>
						<i></i> 
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.services.servicesList.servicename") %></label>
						<span><input type="text" id="servicename" name="servicename" value="" /></span>
					</li>
				</ul>
			</div>
		</div>
		<div class="button-group">
			<input type="button" class="btn btn-default" id="butQuery"
				name="butQuery"
				value="<%=MessageResourcesUtils.getMessage(request, "common.button.query") %>" />
		</div>
		<table width="100%">
			<tbody>
				<tr>
					<td>
						<table id="datagrid"></table>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</form>
<script type="text/javascript">
	$(document).ready(function() {
		//加载分页控件 datagrid
		$('#datagrid').issdatagrid({
			formid : 'form1',
			title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargeInfo.list.title") %>',
			width : 'auto',
			nowrap : true,
			autoRowHeight : false,
			singleSelect : true,
			striped : true,
			//collapsible:true,
			url : '${systemctx}/dailyoperation/chargemanage/querychargeListInfoDataGrid.json',
			sortName : 'modifytime',
			sortOrder : 'desc',
			remoteSort : true,
			idField : 'serviceid',
			pagination : true,
			rownumbers : true,
			showFooter : true,
			queryParams:$('#form1').serializeObject(),
			columns : [ [ {
					field : 'id',
					title : '<%=MessageResourcesUtils.getMessage(request, "common.button.operation") %>',
					width : 100,
					align : 'center',
					formatter : operate
				},{
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.services.servicesList.servicenum") %>',
					field : 'servicenum',
					width : 140,
					sortable : true,
					align : 'left',
					formatter: function(value,row,index){
							return "<a href=\"javascript:void(0);\" onclick=\"view('"+row.serviceid+"')\">"+value+"</a>";
					}
				}, {
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.services.servicesList.servicename") %>',
					field : 'servicename',
					width : 160,
					sortable : true,
					align : 'left'
				}, {
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargemanage.isproposed") %>',
					field : 'isproposed',
					width : 100,
					sortable : true,
					align : 'center'
				}, {
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargemanage.proposedprice") %>',
					field : 'proposedprice',
					width : 100,
					sortable : true,
					align : 'right',
					formatter: function(value,row,index){
						if(value == "0.00")
							return "";
						else
							return value;
					}
				}, {
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargemanage.ismonth") %>',
					field : 'ismonth',
					width : 100,
					sortable : true,
					align : 'center'
				}, {
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargemanage.monthprice") %>',
					field : 'monthprice',
					width : 100,
					sortable : true,
					align : 'right',
					formatter: function(value,row,index){
						if(value == "0.00")
							return "";
						else
							return value;
					}
				},{
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.services.storeservicesguajieList.checkstatus") %>',
					field : 'checkstatus',
					width : 100,
					sortable : true,
					align : 'center'
				},{
					field : 'serviceid',
					hidden: true
				} ] ],
				onLoadSuccess : function(data) {
					//显示AJAX请求后的提示信息
				}
			});

			$('#butQuery').click(function() {
				$('#datagrid').datagrid('load',$('#form1').serializeObject());
			});
			
			function operate(val, row) {
				var id = row.id;
				var serviceid = row.serviceid;
				var checkstatus = row.checkstatus;
				if(id == '' || id == null || checkstatus == '<%=SysConstant.CheckStatus.getName(SysConstant.CheckStatus.CHECKED)%>'){
					return '<a href="javascript:void(0);" class="easyui-linkbutton" onclick="chargeupdate('+serviceid+')"><%=MessageResourcesUtils.getMessage(request, "common.button.update") %></a>'+
						   '<a disabled="disabled" class="easyui-linkbutton disabled" style="color:grey"><%=MessageResourcesUtils.getMessage(request, "common.button.delete") %></a>';
				}else{
					return '<a href="javascript:void(0);" class="easyui-linkbutton" onclick="chargeupdate(' + serviceid + ')"><%=MessageResourcesUtils.getMessage(request, "common.button.update") %></a>'+
					'<a href="javascript:void(0);" class="easyui-linkbutton" onclick="chargedelete(' + id + ')"><%=MessageResourcesUtils.getMessage(request, "common.button.delete") %></a> ';
				}
			}
	});
	
	function chargedelete(val){
		var id = val;
		if (confirm("<%=MessageResourcesUtils.getMessage(request, "alertinfo.common.jsp.alert2") %>")) {
			//正在执行...
			showSending();
			$.ajax({
				type : 'GET',
				url : '${systemctx}/dailyoperation/chargemanage/deleteCharge.json?id=' + id,
				dataType : 'json',
				success : function(data) {
					//关闭执行...
					closeSending();
					//显示AJAX请求后的提示信息
					$.fn.ajaxmessage(data);
					$('#datagrid').datagrid('reload',
					$('#form1').serializeObject());
					$('#datagrid').datagrid('clearSelections');
				}
			});
		}
	}
	
	function chargeupdate(val){
		var serviceid = val;
		$(this).isswindow({
			noheader : true,
			url : '${systemctx}/dailyoperation/chargemanage/toChargeAddOrUpdate.web?serviceid=' + serviceid
		});
	}
	
	/* function view(val){
		var serviceid = val;
		$(this).isswindow({
			noheader : true,
			url : '${systemctx}/dailyoperation/chargemanage/toChargeAddOrUpdate.web?serviceid=' + serviceid
		});
	} */
	function view(val){
		var serviceid = val;
		$(this).isswindow({
			noheader : true,
			url : '${systemctx}/dailyoperation/chargemanage/intochargeView.web?serviceid=' + serviceid
		});
	}

</script>
<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp"%>